#include<stdio.h>
int main()
{
	int a[10][10] ,n,i,j,m;
	printf("请输入行数或列数:\n");
	scanf("%d",&n);
	if(n%2==0){
		m = n/2;
	}else{
		m = (n+1)/2;
	}
	for(i=0; i<m; i++){  //控制列
		for(j=i; j<n-i; j++){
			a[i][j] = i+1;         //上
			a[n-1-i][j] = i+1;     //下
			a[j][i] = i+1;         //左
			a[j][n-1-i] = i+1;     //右
		}	
	}

	//输出
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d\t",a[i][j]);
		}
		printf("\n");
	}

	return 0;
}
